#pragma once

#include <bits/stdc++.h>
#include <unistd.h>
#include <functional>
#include <ctime>
#include <sys/types.h>
#include <sys/wait.h>
using task_t = std::function<void()>;

void Download()
{
    std::
            cout
        << "I am a task to Download"
        << " hanlder : " << getpid() << std::endl;
}

void Printlog()
{
    std::
            cout
        << "I  am a task to record log"
        << " hanlder : " << getpid() << std::endl;
}

void GetSeeds()
{
    std::
            cout
        << "I  am a task to Get Seeds"
        << " hanlder : " << getpid() << std::endl;
}

class Init
{
    const int g_download_code = 0;
    const int g_PrintLog_code = 1;
    const int g_GetSeeds_code = 2;

public:
    std ::vector<task_t> tasks;
    Init()
    {
        tasks.push_back(Download);
        tasks.push_back(Printlog);
        tasks.push_back(GetSeeds);
    }
    bool CheckSafe(int code)
    {
        if (code >= 0 && code < tasks.size())
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
    void RunTask(int code)
    {
        return tasks[code]();
    }
    int SelectTask()
    {
        return rand() % tasks.size();
    }
};

Init init;